package beans.bytee;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;

public class ObjectTest
{

	public static void main(String[] args)
	{
		int[] bytes = new int[4];
		O.addOne(bytes);
		for (int b : bytes)
			System.out.println("ObjectTest.main()" + b);
		System.out.println("1===========================");

		Sequencer sequencer = new Sequencer();
		System.out.println("ObjectTest.main()" + sequencer.next());
		System.out.println("ObjectTest.main()" + sequencer.next());
		System.out.println("ObjectTest.main()" + sequencer.next());
		System.out.println("2===========================");

		AtomicBoolean ab = new AtomicBoolean(true);
		System.out.println("ObjectTest.main()" + ab.get());
		ab.compareAndSet(false, true);
		System.out.println("ObjectTest.main()" + ab.get());
		System.out.println("4===========================");

		System.out.println("ObjectTest.main()" + System.currentTimeMillis());
		System.out.println("5===========================");
	}
}

class O
{
	/**
	 * 传进来的bytes,方法内修改，方法外有效。
	 * 
	 * @param bytes
	 */
	public static void addOne(int[] bytes)
	{
		int i = 0;
		for (int b : bytes)
			bytes[i++] = ++b;
	}
}

class Sequencer
{
	private final AtomicLong sequenceNumber = new AtomicLong(0);

	public long next()
	{
		return sequenceNumber.getAndIncrement();
	}
}
